]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
windowMenu: Add an entry to take a screenshot
authorIvan Molodetskikh <yalterz@gmail.com>
Fri, 27 Aug 2021 16:17:46 +0000 (19:17 +0300)
committerMarge Bot <marge-bot@gnome.org>
Sat, 12 Feb 2022 00:20:54 +0000 (00:20 +0000)
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2105>

js/ui/windowMenu.js

index 27cecdac23776ac99a73255bf84c5b86bc52de52..081645f04238c9682114541a8af7fb94409a4b3a 100644 (file)
@@ -6,6 +6,7 @@ const { GLib, Meta, St } = imports.gi;
 const BoxPointer = imports.ui.boxpointer;
 const Main = imports.ui.main;
 const PopupMenu = imports.ui.popupMenu;
+const Screenshot = imports.ui.screenshot;
 
 var WindowMenu = class extends PopupMenu.PopupMenu {
     constructor(window, sourceActor) {
@@ -24,6 +25,19 @@ var WindowMenu = class extends PopupMenu.PopupMenu {
 
         let item;
 
+        // Translators: entry in the window right click menu.
+        item = this.addAction(_('Take Screenshot'), async () => {
+            try {
+                const actor = window.get_compositor_private();
+                const content = actor.paint_to_content(null);
+                const texture = content.get_texture();
+
+                await Screenshot.captureScreenshot(texture, null, 1, null);
+            } catch (e) {
+                logError(e, 'Error capturing screenshot');
+            }
+        });
+
         item = this.addAction(_('Hide'), () => {
             window.minimize();
         });